﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using Shove.Web.UI;

public partial class UserControls_GoodSearch_New : UCBase
{
    public string StringBuilders = "";

    public UserControls_GoodSearch_New()
    {
        Name = "商品搜索_2";

        //swpas = new ShoveWebPartAttribute[1];

        //swpas[0] = new ShoveWebPartAttribute_Int("热门商品个数", "10", 1004, "控件的宽度");
        //swpas[1] = new ShoveWebPartAttribute_Int("搜索图片宽度", "1,300", 67, "搜索图片宽度");
        //swpas[2] = new ShoveWebPartAttribute_Int("搜索图片高度", "1,300", 30, "搜索图片高度");
        //swpas[3] = new ShoveWebPartAttribute_Int("下拉框宽度", "1,1000", 120, "下拉框宽度");

        //swpas[4] = new ShoveWebPartAttribute_Image("搜索图片", "", "images/UserControls/Search_01.gif", "搜索图片");
        //swpas[5] = new ShoveWebPartAttribute_Image("搜索按钮图片", "", "images/UserControls/search_btn.gif", "搜索按钮图片");

        //swpas[6] = new ShoveWebPartAttribute_Text("提示文字CSS样式", "", "white12", "提示文字CSS样式");
        //swpas[7] = new ShoveWebPartAttribute_Text("文本框CSS样式", "", "", "文本框CSS样式");
        //swpas[8] = new ShoveWebPartAttribute_Text("提示类别CSS样式", "", "white14", "提示类别CSS样式");
        //swpas[9] = new ShoveWebPartAttribute_Text("搜索关键字", "", "美白,保湿,祛皱,防敏,去油,补水,防晒", "搜索关键字");

        //swpas[10] = new ShoveWebPartAttribute_Color("控件背景颜色", "#DE4C7D", "控件背景颜色");
    }

    public void IniltLayOut()
    {
        //tabctr.Width = swpAttributes[0];
        //tabctr.BgColor = swpAttributes[10];
        //imgSerch.Width = Shove._Convert.StrToInt(swpAttributes[1], 67);
        //imgSerch.Height = Shove._Convert.StrToInt(swpAttributes[2], 30);
        //imgSerch.Src = "~/" + swpAttributes[4];
        //ImgBtnSearch.ImageUrl = "~/" + swpAttributes[5];

        //txtKeyWord.CssClass = swpAttributes[7];
        ////ddlGoodType.Width = new Unit(swpAttributes[3]);
        //lbSelect.CssClass = swpAttributes[8];
        //tdhelp.Attributes.Add("class", swpAttributes[6]);

        //if (!string.IsNullOrEmpty(swpAttributes[9]))
        //{
        //    string[] str = swpAttributes[9].Split(',');

        //    for (int i = 0; i < str.Length; i++)
        //    {
        //        tdhelp.InnerHtml += str[i] + "&nbsp;&nbsp;";
        //    }
        //}
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        IniltLayOut();
        LoadHotGoods();
        LoadGoodType();        
    }

    /// <summary>
    /// 加载热门商品
    /// </summary>
    private void LoadHotGoods()
    {
        DataTable dt = null;
        int Count = 10;

        dt = new DAL.Views.V_Shop_ShopStock().Open("top " + Count + " *", "isHot = 1 and ShopID = " + _Site.ID, "[upDate]");

        if (dt != null && dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                StringBuilders += "<span><a href='#' class='Meun_link'> " + dt.Rows[i]["GoodName_CN"].ToString() + "</a> </span><span class='bs'> | </span>";
            }
        }
    }

    /// <summary>
    /// 加载商品类型
    /// </summary>
    private void LoadGoodType()
    {
        DataTable dt = null;

        dt = new DAL.Tables.tbl_Shop_GoodType().Open("", "ShopID = " + _Site.ID + " and TypeStatus = 1", "");
        
        ddlGoodType.DataTextField = "TypeName";
        ddlGoodType.DataValueField = "ID";

        ddlGoodType.DataSource = dt;
        ddlGoodType.DataBind();
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string KeyWord = txtKeyWord.Text.Trim();
        string GoodType = ddlGoodType.SelectedValue;

        Response.Redirect("Default.aspx?PN=goods_search_list&Page=Search&GoodType=" + GoodType + "&KeyWord=" + KeyWord);
        
    }
}
